<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 石子游戏 VI -->
    <script>
      var stoneGameVI = function (aliceValues, bobValues) {
        let alice = (bob = 0)
        let len = aliceValues.length
        let temp = []
        for (let i = 0; i < len; i++) temp[i] = [aliceValues[i] + bobValues[i], i]
        temp.sort((a, b) => b[0] - a[0])
        for (let i = 0; i < len; i++) {
          if (i % 2 == 0) alice += aliceValues[temp[i][1]]
          else bob += bobValues[temp[i][1]]
        }
        return alice > bob ? 1 : alice == bob ? 0 : -1
      }
      console.log(stoneGameVI([1, 3], [2, 1]))
    </script>
  </body>
</html>
